﻿using TodoList.Data;
using TodoList.MinimalApi.DTOs;
using TodoList.Shared;

namespace TodoList.MinimalApi.Mapper;

public static class TodoItemMapper
{
    public static TodoItem ToEntity(this CreateTodoItemRequest request)
    {
        return new TodoItem
        {
            Title = request.Title,
            Description = request.Description,
            IsCompleted = request.IsCompleted,
            DueDate = request.DueDate
        };
    }
    
    public static void UpdateEntity(this TodoItem item, UpdateTodoItemRequest request)
    {
        item.Title = request.Title;
        item.Description = request.Description;
        item.IsCompleted = request.IsCompleted;
        item.DueDate = request.DueDate;
    }
}
